package section6_4;

import java.util.concurrent.PriorityBlockingQueue;

/**
 * Created by Hyman on 2017/6/15.
 *
 * 任务对象，生成1000个事件，并且将其存放在一个优先队列中
 */
public class Task implements Runnable {

    private int id;
    private PriorityBlockingQueue<Event> queue;

    public Task(int id, PriorityBlockingQueue<Event> queue) {
        this.id = id;
        this.queue = queue;
    }

    @Override
    public void run() {
        for(int i=0; i<1000; i++) {
            Event event = new Event(id, i);
            queue.add(event);
        }
    }
}
